package com.zhuss.advice.processor;

import com.zhuss.advice.db.dao.ext.ProposalSonDao;
import com.zhuss.bean.bo.advice.proposalSon.SearchProposalSonBo;
import com.zhuss.bean.vo.advice.proposalSon.ListProposalSonVo;
import com.zhuss.common.PageVo;
import com.zhuss.exception.WpsException;
import com.zhuss.exception.ExceptionCode;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * @Author: zhushanshuo
 * @Date: 2020/3/6 16:47
 */
@Component("proposalSonRead")
public class ProposalSonRead {

    @Autowired
    private ProposalSonDao proposalSonDao;

    /**
     户列表
     * @param bo
     */
    public Object list(SearchProposalSonBo bo) {
        PageVo<ListProposalSonVo> result = new PageVo<ListProposalSonVo>();
        result.setPageNum(bo.getPageNum());
        result.setPageSize(bo.getPageSize());
        result.setItems(proposalSonDao.list(bo));
        result.setTotal(proposalSonDao.countList(bo));
        return result;
    }

    /**
     * 详情
     * @throws WpsException
     */
    public Object detail(Long proposalId) throws WpsException {
        Object result = proposalSonDao.detail(proposalId);
        if (result == null) {
            throw new WpsException(ExceptionCode.数据不存在);
        }
        return result;
    }
}
